package com.panda.mall.user.level.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.panda.mall.common.mallUser.entity.MallUserLevel;
import com.panda.mall.user.level.service.MallUserLevelService;
import com.panda.mall.user.level.mapper.MallUserLevelMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author tucy123
* @description 针对表【mall_user_level(用户等级表)】的数据库操作Service实现
* @createDate 2023-06-13 11:31:36
*/
@Service
public class MallUserLevelServiceImpl extends ServiceImpl<MallUserLevelMapper, MallUserLevel> implements MallUserLevelService{

    @Autowired
    MallUserLevelMapper mallUserLevelMapper;
    /**
     * 新增或修改商城等级
     * @param mallUserLevel
     * @return
     */
    @Override
    public String saveOrUpdateLevel(MallUserLevel mallUserLevel) {
        boolean update = this.saveOrUpdate(mallUserLevel);
        return update ? "成功":"失败";
    }

    /**
     * 查询全部商城等级
     * @return
     */
    @Override
    public List<MallUserLevel> queryList() {
        return this.lambdaQuery().list();
    }

    /**
     * 查询商城等级详细
     * @param id
     * @return
     */
    @Override
    public MallUserLevel queryLevelById(Long id) {
        return mallUserLevelMapper.selectById(id);
    }

    /**
     * 删除商城等级
     * @param ids
     * @return
     */
    @Override
    public String deleteLevel(List<Long> ids) {
        int i = mallUserLevelMapper.deleteBatchIds(ids);
        return (i != 0) ? "操作成功" : "操作失败";
    }
}
